<!DOCTYPE html>
<script src="../../../resources/js-test.js"></script>
<script src="resources/currentSrcHelper.js"></script>
<script>
    if (window.testRunner)
        testRunner.dumpAsText();

    addEventListener("load", function() {
        shouldBe('document.getElementById("canary").clientWidth', '75');
        shouldBe('currentSrcFileName("canary")', '"blue_rect.jpg?0"');
        shouldBe('document.getElementById("picture_in_picture").clientWidth', '800');
        shouldBe('currentSrcFileName("picture_in_picture")', '"image-set-2x.png?2"');
        shouldBe('document.getElementById("picture_in_div_in_picture").clientWidth', '800');
        shouldBe('currentSrcFileName("picture_in_div_in_picture")', '"image-set-2x.png?2"');
        shouldBe('document.getElementById("picture_in_div_with_source_above").clientWidth', '800');
        shouldBe('currentSrcFileName("picture_in_div_with_source_above")', '"image-set-2x.png?2"');
        shouldBe('document.getElementById("picture_in_the_way").clientWidth', '800');
        shouldBe('currentSrcFileName("picture_in_the_way")', '"image-set-2x.png?2"');
        shouldBe('document.getElementById("picture_in_picture_1").clientWidth', '800');
        shouldBe('currentSrcFileName("picture_in_picture_1")', '"image-set-2x.png?2"');
        shouldBe('document.getElementById("picture_in_picture_2").clientWidth', '800');
        shouldBe('currentSrcFileName("picture_in_picture_2")', '"image-set-2x.png?2"');
        shouldBe('document.getElementById("picture_at_end").clientWidth', '75');
        shouldBe('currentSrcFileName("picture_at_end")', '"blue_rect.jpg?52"');
        shouldBe('document.getElementById("picture_no_source").clientWidth', '75');
        shouldBe('currentSrcFileName("picture_no_source")', '"blue_rect.jpg?6"');
    }, false);
</script>
<!-- A canary image to see that the test is actually working -->
<img id="canary" src="resources/blue_rect.jpg?0">
<!-- nested element tests -->
<picture>
    <picture>
        <source sizes="800px" srcset="../../hidpi/resources/image-set-1x.png?2 400w, ../../hidpi/resources/image-set-2x.png?2 800w,
            resources/image-set-4x.png?2 1600w">
        <img id="picture_in_picture" src="resources/blue_rect.jpg?1">
    </picture>
</picture>
<picture>
    <div>
        <picture>
            <source sizes="800px" srcset="../../hidpi/resources/image-set-1x.png?2 400w, ../../hidpi/resources/image-set-2x.png?2 800w,
                resources/image-set-4x.png?2 1600w">
            <img id="picture_in_div_in_picture" src="resources/blue_rect.jpg?2">
        </picture>
    </div>
</picture>
<picture>
    <source sizes="800px" srcset="../../hidpi/resources/image-set-1x.png?2 400w, ../../hidpi/resources/image-set-2x.png?2 800w,
        resources/image-set-4x.png?2 1600w">
    <div>
        <picture>
            <source sizes="800px" srcset="../../hidpi/resources/image-set-1x.png?2 400w, ../../hidpi/resources/image-set-2x.png?2 800w,
                resources/image-set-4x.png?2 1600w">
            <img id="picture_in_div_with_source_above" src="resources/blue_rect.jpg?4">
        </picture>
    </div>
    <img id="picture_in_the_way" src="resources/blue_rect.jpg?4">
</picture>
<picture>
    <picture>
        <source sizes="800px" srcset="../../hidpi/resources/image-set-1x.png?2 400w, ../../hidpi/resources/image-set-2x.png?2 800w,
            resources/image-set-4x.png?2 1600w">
        <img id="picture_in_picture_1" src="resources/blue_rect.jpg?5">
        <img id="picture_in_picture_2" src="resources/blue_rect.jpg?51">
    </picture>
    <img id="picture_at_end" src="resources/blue_rect.jpg?52">
</picture>
<picture>
    <img id="picture_no_source" src="resources/blue_rect.jpg?6">
</picture>
